#ifndef __LIB_WINBUF_H__
#define __LIB_WINBUF_H__

#include <nxos.h>

/* libwinbuf use share memory */
#define CONFIG_WINBUF_SHM

#define UIO_WINBUF_TOP          1
#define UIO_WINBUF_FLUSH        2
#define UIO_WINBUF_INFO         3

#ifdef CONFIG_WINBUF_SHM
#define UIO_WINBUF_SHMNAME      4
#endif

enum {
    WINBUF_MSG_NONE = 0,
    WINBUF_MSG_KEY_DOWN,
    WINBUF_MSG_KEY_UP,
    WINBUF_MSG_MOUSE_MOTION,
    WINBUF_MSG_MOUSE_LBTN_DOWN,
    WINBUF_MSG_MOUSE_LBTN_UP,
    WINBUF_MSG_MOUSE_LBTN_DBLCLK,
    WINBUF_MSG_MOUSE_RBTN_DOWN,
    WINBUF_MSG_MOUSE_RBTN_UP,
    WINBUF_MSG_MOUSE_RBTN_DBLCLK,
    WINBUF_MSG_MOUSE_MBTN_DOWN,
    WINBUF_MSG_MOUSE_MBTN_UP,
    WINBUF_MSG_MOUSE_MBTN_DBLCLK,
    WINBUF_MSG_MOUSE_WHEEL_UP,
    WINBUF_MSG_MOUSE_WHEEL_DOWN,
    WINBUF_MSG_MOUSE_WHEEL_LEFT,
    WINBUF_MSG_MOUSE_WHEEL_RIGHT,
    WINBUF_MSG_NR,
};

typedef struct WinbufMsg
{
    NX_U32 id;
    NX_U32 data0;
    NX_U32 data1;
    NX_U32 data2;
} WinbufMsg;

typedef struct WinbufInfo
{
    NX_Size width;
    NX_Size height;
    NX_Size bpp; /* bits per pixel */
} WinbufInfo;

#define SetWinbufMsgId(msg, _id) ((msg)->id = (_id))
void SetWinbufMsgData(WinbufMsg * msg, NX_U32 data0, NX_U32 data1, NX_U32 data2);
void ClearWinbufMsg(WinbufMsg * msg);

#define GetWinbufMsgId(msg)         ((msg)->id)
#define GetWinbufMsgCode(msg)       ((msg)->data0)
#define GetWinbufMsgKeyModify(msg)  ((msg)->data1)
#define GetWinbufMsgX(msg)          ((msg)->data0)
#define GetWinbufMsgY(msg)          ((msg)->data1)
#define GetWinbufMsgWheel(msg)      ((int)(msg)->data2)

#endif /* __LIB_WINBUF_H__ */

